package com.ruoyi.Application.service.impl;

import java.util.List;

import com.ruoyi.labortary.domain.AlgsLaboratory;
import com.ruoyi.labortary.mapper.AlgsLaboratoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.Application.mapper.AlgsLaboratoryApplicationMapper;
import com.ruoyi.Application.domain.AlgsLaboratoryApplication;
import com.ruoyi.Application.service.IAlgsLaboratoryApplicationService;

/**
 * 实验室申请Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-16
 */
@Service
public class AlgsLaboratoryApplicationServiceImpl implements IAlgsLaboratoryApplicationService 
{
    @Autowired
    private AlgsLaboratoryApplicationMapper algsLaboratoryApplicationMapper;
    @Autowired
    private AlgsLaboratoryMapper algsLaboratoryMapper;

    /**
     * 查询实验室申请
     * 
     * @param laboratoryApplicationId 实验室申请主键
     * @return 实验室申请
     */
    @Override
    public AlgsLaboratoryApplication selectAlgsLaboratoryApplicationByLaboratoryApplicationId(Long laboratoryApplicationId)
    {
        return algsLaboratoryApplicationMapper.selectAlgsLaboratoryApplicationByLaboratoryApplicationId(laboratoryApplicationId);
    }

    /**
     * 查询实验室申请列表
     * 
     * @param algsLaboratoryApplication 实验室申请
     * @return 实验室申请
     */
    @Override
    public List<AlgsLaboratoryApplication> selectAlgsLaboratoryApplicationList(AlgsLaboratoryApplication algsLaboratoryApplication)
    {
        return algsLaboratoryApplicationMapper.selectAlgsLaboratoryApplicationList(algsLaboratoryApplication);
    }

    /**
     * 新增实验室申请
     * 
     * @param algsLaboratoryApplication 实验室申请
     * @return 结果
     */
    @Override
    public int insertAlgsLaboratoryApplication(AlgsLaboratoryApplication algsLaboratoryApplication)
    {
        Long laboratoryId = algsLaboratoryApplication.getLaboratoryId();
       AlgsLaboratory algsLaboratory = algsLaboratoryMapper.selectAlgsLaboratoryByLaboratoryId(laboratoryId);
        algsLaboratory.setTypeId(24L);
        algsLaboratoryMapper.updateAlgsLaboratory(algsLaboratory);
        return algsLaboratoryApplicationMapper.insertAlgsLaboratoryApplication(algsLaboratoryApplication);
    }

    /**
     * 修改实验室申请
     * 
     * @param algsLaboratoryApplication 实验室申请
     * @return 结果
     */
    @Override
    public int updateAlgsLaboratoryApplication(AlgsLaboratoryApplication algsLaboratoryApplication)
    {
        return algsLaboratoryApplicationMapper.updateAlgsLaboratoryApplication(algsLaboratoryApplication);
    }

    /**
     * 批量删除实验室申请
     * 
     * @param laboratoryApplicationIds 需要删除的实验室申请主键
     * @return 结果
     */
    @Override
    public int deleteAlgsLaboratoryApplicationByLaboratoryApplicationIds(Long[] laboratoryApplicationIds)
    {
        return algsLaboratoryApplicationMapper.deleteAlgsLaboratoryApplicationByLaboratoryApplicationIds(laboratoryApplicationIds);
    }

    /**
     * 删除实验室申请信息
     * 
     * @param laboratoryApplicationId 实验室申请主键
     * @return 结果
     */
    @Override
    public int deleteAlgsLaboratoryApplicationByLaboratoryApplicationId(Long laboratoryApplicationId)
    {
        return algsLaboratoryApplicationMapper.deleteAlgsLaboratoryApplicationByLaboratoryApplicationId(laboratoryApplicationId);
    }
}
